package hn.cch.client;

import hn.cch.commom.EchoCommon;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class EchoClient {

    public static void main(String[] args) {
        try {



            //Registry实现
            Registry registry = LocateRegistry.getRegistry(8808);
            EchoCommon echoCommon = (EchoCommon) registry.lookup("echo");

            //Naming实现
            // String string = "rmi://0.0.0.0:8808/echo";
            // EchoCommon echoCommon = (EchoCommon) Naming.lookup(string);



            System.out.println("EchoClient Naming lookup 8808/echo");
            System.out.println(echoCommon.echoString("HelloWorld"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
